Conditions | 1 |
Paths | 1 |
Total Lines | 38 |
Code Lines | 25 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | 'use strict' |
||
9 | module.exports = (baseFileDir, source, params, callback) => { |
||
10 | debug('Searching for issue: %s', params.summary) |
||
11 | |||
12 | const searchUrl = source.url + '/rest/api/2/search/' |
||
13 | const summary = replaceTextFileString(baseFileDir, params.summary) |
||
14 | const jql = 'project="' + source.project + '" AND summary~"' + summary + '" ORDER BY id DESC' |
||
15 | |||
16 | let search = { |
||
17 | jql: jql, |
||
18 | maxResults: 1, |
||
19 | fields: [ |
||
20 | 'key', |
||
21 | 'summary' |
||
22 | ] |
||
23 | } |
||
24 | |||
25 | debug('Sending search: %s', jql) |
||
26 | |||
27 | request({ |
||
28 | method: 'POST', |
||
29 | uri: searchUrl, |
||
30 | auth: { |
||
31 | username: source.username, |
||
32 | password: source.password |
||
33 | }, |
||
34 | json: search |
||
35 | }, (error, response, body) => { |
||
36 | if ( error ) { |
||
37 | callback(error) |
||
38 | } |
||
39 | |||
40 | debugResponse(response) |
||
41 | |||
42 | let issue = body.issues[0] |
||
43 | |||
44 | callback(null, issue) |
||
45 | }) |
||
46 | } |
||
47 |